package com.mryang.ladder;

import java.util.Scanner;

/**
 * @ClassName L1_019
 * @Description TODO 划拳
 *                   给出甲、乙两人的酒量（最多能喝多少杯不倒）和划拳记录，请你判断两个人谁先倒
 *
 * @Author Genius
 * @Date 2021/2/1 18:46
 */
public class L1_019 {
    public static void main(String[] args) {
        Scanner scr = new Scanner(System.in);
        // A、B的酒量
        int tipsyA = scr.nextInt();
        int tipsyB = scr.nextInt();

        // A、B喝的杯数
        int countA = 0;
        int countB = 0;

        // 进行 numberRounds 轮猜拳
        int numberRounds = scr.nextInt();
        int[][] buildWould = new int[numberRounds][4];
        for (int i = 0; i < numberRounds; i++) {
            for (int j = 0; j < 4; j++) {
                buildWould[i][j] = scr.nextInt();
            }
        }

        // 判断输赢
        for (int i = 0; i < numberRounds; i++) {
            // 对于甲:
            if(buildWould[i][1] == buildWould[i][0] + buildWould[i][2] && buildWould[i][3] != buildWould[i][0] + buildWould[i][2]){
                countA++;
            }
            // 对于乙:
            if(buildWould[i][3] == buildWould[i][0] + buildWould[i][2] && buildWould[i][1] != buildWould[i][0] + buildWould[i][2]){
                countB++;
            }
            // 甲、乙都输或都赢
            if(buildWould[i][1] == buildWould[i][0] + buildWould[i][2] && buildWould[i][3] == buildWould[i][0] + buildWould[i][2]) {
                countA++;
                countB++;
            }
            // 判断输赢
            if(countA >= tipsyA){
                System.out.println("A");
                System.out.println(countB);
                return;
            }else if(countB >= tipsyB){
                System.out.println("B");
                System.out.println(countA);
                return;
            }
        }
    }
}
